home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
VISUALBA
/
LOADGIF.ZIP
/
LOADGIF.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-08-20
|
45KB
|
1,459 lines
;LOADGIF.ASM v1.0 - Optimized GIF Loader for EGA and VGA Video Modes
;By Rich Geldreich, Jr.
;Last Modified August 20, 1993
;Assembled with TASM v2.0
IDEAL
MODEL SMALL
;-------------------------------------------------------------------------------
MACRO PushaMacro
Push ax
Push bx
Push cx
Push dx
Push si
Push di
Push bp
ENDM PushaMacro
;-------------------------------------------------------------------------------
MACRO PopaMacro
Pop bp
Pop di
Pop si
Pop dx
Pop cx
Pop bx
Pop ax
ENDM PopaMacro
;-------------------------------------------------------------------------------
;This equate specifies the size the disk I/O buffer.
;Make sure it's at least 1024 or so bytes long.
DiskIOSize = 8192
;-------------------------------------------------------------------------------
RP = 0
;-------------------------------------------------------------------------------
;I/O Control.
BufferOffset = RP
RP = RP + 2
BufferLeft = RP
RP = RP + 2
BufferHandle = RP
RP = RP + 2
EOFFlag = RP
RP = RP + 2
;-------------------------------------------------------------------------------
;GIF Decoding & Image Size.
TotalX = RP
RP = RP + 2
TotalY = RP
RP = RP + 2
NumColors = RP
RP = RP + 2
XStart = RP
RP = RP + 2
YStart = RP
RP = RP + 2
XLength = RP
RP = RP + 2
YLength = RP
RP = RP + 2
XEnd = RP
RP = RP + 2
YEnd = RP
RP = RP + 2
X = RP
RP = RP + 2
Y = RP
RP = RP + 2
;-------------------------------------------------------------------------------
;View window & Upper left hand corner of GIF image.
XOrg = RP
RP = RP + 2
YOrg = RP
RP = RP + 2
X0 = RP
RP = RP + 2
Y0 = RP
RP = RP + 2
X1 = RP
RP = RP + 2
Y1 = RP
RP = RP + 2
;-------------------------------------------------------------------------------
;Hardware parameters.
VidColors = RP
RP = RP + 2
Handler = RP
RP = RP + 2
ScrOffset = RP
RP = RP + 2
ScrWidth = RP
RP = RP + 2
ScrX = RP
RP = RP + 2
ScrY = RP
RP = RP + 2
PixsLeft = RP
RP = RP + 2
AdapterType = RP
RP = RP + 2
PalIgnore = RP
RP = RP + 2
;-------------------------------------------------------------------------------
;LZW Decompression.
PassNumber = RP
RP = RP + 2
PassStep = RP
RP = RP + 2
Background = RP
RP = RP + 2
NoPalette = RP
RP = RP + 2
Interlaced = RP
RP = RP + 2
FirstCode = RP
RP = RP + 2
StartCode = RP
RP = RP + 2
StartMaxCode = RP
RP = RP + 2
NextCode = RP
RP = RP + 2
LastCode = RP
RP = RP + 2
LastPixel = RP
RP = RP + 2
StartCodeMask = RP
RP = RP + 2
StartCodeSize = RP
RP = RP + 2
;-------------------------------------------------------------------------------
;Scanline buffer. A maximum of 1536 pixels per scanline should be enough.
LineBuffer = RP
RP = RP + 1536
;-------------------------------------------------------------------------------
;LZW string tables. The Suffix table MUST come directly before Prefix in memory!
Suffix = RP
RP = RP + 4096*2
Prefix = RP
RP = RP + 4096*2
PStack = RP
RP = RP + 4096+128
;-------------------------------------------------------------------------------
;GIF's palette.
Palette = RP
RP = RP + 768
;-------------------------------------------------------------------------------
;Disk I/O buffer.
RP = RP + 16
DiskBuffer = RP
RP = RP + DiskIOSize
;-------------------------------------------------------------------------------
;For 16 color pixel plotting.
Plane0 = RP
RP = RP + 80
Plane1 = RP
RP = RP + 80
Plane2 = RP
RP = RP + 80
Plane3 = RP
RP = RP + 80
;-------------------------------------------------------------------------------
;The value of RP here determines how much memory the function requires.
;-------------------------------------------------------------------------------
SEGMENT GIFCODE PARA PUBLIC 'CODE'
;-------------------------------------------------------------------------------
ASSUME DS:@DATA, ES:@DATA, CS:GIFCODE, SS:@DATA
;-------------------------------------------------------------------------------
;In ERROR.ASM
EXTRN ErrorCode:WORD
EXTRN Hook24:NEAR, Unhook24:NEAR, CheckError:NEAR
;-------------------------------------------------------------------------------
PUBLIC LoadGIF
PROC LoadGIF
;Stack organization.
MemPointer EQU [ss:bp+42]
FileSeg EQU [ss:bp+40]
FileOfs EQU [ss:bp+38]
PScrType EQU [ss:bp+36]
PScrOffset EQU [ss:bp+34]
PScrWidth EQU [ss:bp+32]
PXRes EQU [ss:bp+30]
PYRes EQU [ss:bp+28]
PX0 EQU [ss:bp+26]
PY0 EQU [ss:bp+24]
PX1 EQU [ss:bp+22]
PY1 EQU [ss:bp+20]
PXOrg EQU [ss:bp+18]
PYOrg EQU [ss:bp+16]
PAdapterType EQU [ss:bp+14]
PPalIgnore EQU [ss:bp+12]
PPalSeg EQU [ss:bp+10]
PPalOfs EQU [ss:bp+08]
PPalColors EQU [ss:bp+06]
Parameters = 19
Cld
Push bp
Mov bp, sp
Push ds es si di
Call Hook24 ;Install critical error handler.
Mov ax, MemPointer
Mov ds, ax
Mov es, ax
Call Init ;Fetch passed parameters.
Jc @@OpenError
Call CheckOpts ;Check passed window coordinates.
Jc @@NothingToDo
Call IOOpen ;Open GIF file.
Jc @@OpenError
Call IOReadInit ;Initialize disk I/O buffer.
Jc @@Error
Call GetGIFHeader ;Fetch GIF sig, tables, etc.
Jc @@Error
Call SetPalette ;Set GIF's palette.
Call DecodeGIF ;Decompress GIF.
Jc @@Error
Xor ax, ax ;No error.
@@Exit0: Push ax
Call IOClose ;Close input file.
Pop ax
@@Exit1: Call Unhook24 ;Uninstall critical error handler.
Cld
Pop di si es ds bp
Retf Parameters*2
@@Error: Mov ax, -1
Jmp @@Exit0
@@OpenError: Mov ax, -1
Jmp @@Exit1
@@NothingToDo: Xor ax, ax
Jmp @@Exit1
ENDP LoadGIF
;-------------------------------------------------------------------------------
PROC Init
;---------------
;Clear work space.
Xor ax, ax
Mov di, offset BufferOffset
Mov cx, RP ;Clear memory block.
Shr cx, 1
Rep Stosw
Rcl cx, 1
Rep Stosb
;---------------
;Fetch & check passed parameters from stack.
Mov ax, PScrType
Cmp ax, 2
Ja @@Error1
Mov bx, offset WPIX1 ;assume mode 13
Mov cx, 256
And ax, ax
Jnz @@10
Mov bx, offset WPIX0 ;16 color modes
Mov cx, 16
@@10:
Cmp al, 2
Jn